package com.dingreading.cloud.admin.service;

import com.dingreading.cloud.admin.dto.GoodsAndTypeDto;
import com.dingreading.cloud.admin.dto.GoodsTypeDto;
import com.dingreading.cloud.admin.dto.GoodsTypeInfoDto;
import com.dingreading.cloud.admin.dto.GoodsTypeNumsDto;
import com.dingreading.cloud.admin.entity.GoodsType;
import com.dingreading.cloud.common.util.PageDto;
import com.dingreading.cloud.common.util.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;

import java.util.List;

/**
 * 服务层。
 *
 * @author Administrator
 * @since 2023-11-22
 */
public interface GoodsTypeService extends IService<GoodsType> {

    // 获取商品规格的最新价格和库存数
    Page<GoodsTypeDto> pageList(PageUtil pageUtil, String name, Long categoryId, Integer enabled);

    int deleteByGoodsIdAndIds(Long goodsId, List<Long> ids);

    List<GoodsType> getByGoodsId(Long goodsId);

    // 批量修改状态
    boolean updateEnabled(Long goodsTypeId, Integer enabled, String staffUid, String staffName);

    boolean getCntByUnit(String name);

    // 获取商品库存数、加权价、已售数
    Page<GoodsTypeNumsDto> goodsStockPage(PageUtil pageUtil, String keyword, Integer orderByType);

    // 获取库存达到预警的数量
    long getGoodsWarningNum();


    /*--------------V3----------------*/
    PageDto<GoodsAndTypeDto> goodsTypePageList(PageUtil pageUtil, String keyword, Integer comboType, Integer enabled);

    List<GoodsTypeInfoDto> typeInfoListByGoodsIdAndEnabled(Long goodsId);

    GoodsType getByGoodsIdAndGoodsTypeId(Long goodsId, Long goodsTypeId);

    int deleteByGoodsIdAndId(Long goodsId, Long id);

    List<GoodsAndTypeDto> goodsTypeList(String keyword, Integer comboType, Integer enabled);

    // 库存预警
    Page<GoodsTypeNumsDto> goodsWarnPage(PageUtil pageUtil, String keyword);

    GoodsType getLtOrderNum(Long goodsId, Integer comboType, Integer orderNum);

    GoodsType getGtOrderNum(Long goodsId, Integer comboType, Integer orderNum);

    void updateOrderNum(Long id, Integer orderNum);

    int getMaxShowOrder(Long goodsId, Integer comboType);

    List<GoodsType> listByGoodsIdIn(List<Long> goodsIds);

    boolean updateDiscountStatus(Long id, Integer discountStatus, String staffUid, String staffName);
}
